import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/login',
      name: 'Login',
      component: () => import("../views/Login")
    },
    {
      path: '/main/:username',
      name: 'Main',
      component: () => import("../views/Main"),
      children: [
        {
          path: "/user/profile/:id",  //传递参数之路径匹配
          name: "UserProfile",
          component: () => import("../views/users/UserProfile")
        },
        {
          path: "/user/list",
          name: "UserList",
          component: () => import("../views/users/UserList")
        },
        {
          path: "/user/role",
          name: "UserRole",
          component: () => import("../views/users/UserRole"),
          props: true
        }
      ]
    },
    {
      path: "/gomain/:username",
      redirect: "/main/:username"
    },
    {
      path: "*",
      name: "Error",
      component: () => import("../views/Error"),
    }
  ]
})
